import axios from 'axios'
export default {
    namespaced: true,
    state: {
        catagtory: [],
        currentCatagtory: ''
    },
    mutations: {
        updateCatagtory(state, payload) {
            state.catagtory = payload // 更新分类数据
        },
        updateCurrentCatagtory(state, payload) {
            state.currentCatagtory = payload
        }
    },
    actions: {
        async getCatagtory(context) {
            const { data: { data: { channels } } } = await axios.get("http://ttapi.research.itcast.cn/app/v1_0/channels")
            context.commit('updateCatagtory', channels)
            context.commit('updateCurrentCatagtory', channels[0].id)
        }
    }
}